<?php

namespace App\Http\Controllers\home;

use App\Http\Controllers\Controller;
use App\Utils\Show;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;

class Index extends Common
{
    //前台首页
    public function index(Request $request)
    {
        $cid = $request->cid;

        //输出轮播图
        $data['banner'] = DB::table('banner')->where('status',0)->lists();
        //输出分类
        $data['cats'] = DB::table('article_cate')->limit(6)->lists();
        //默认输出文章
        $data['art'] = DB::table('article')->where('cid',4)->orderBy('add_time','desc')->limit(10)->lists();
        $data['art1'] = DB::table('article')->where('cid',5)->limit(10)->lists();
        $data['art2'] = DB::table('article')->where('cid',6)->limit(10)->lists();
        $data['art3'] = DB::table('article')->where('cid',7)->limit(10)->lists();
        $data['art4'] = DB::table('article')->where('cid',8)->limit(10)->lists();
        $data['art5'] = DB::table('article')->where('cid',9)->limit(10)->lists();
        $data['admin']   = DB::table('admin')->cates('id');
        $data['user']   = DB::table('member')->cates('id');
        //热门文章
        $data['re'] = DB::table('article')->orderBy('pv','desc')->limit(10)->lists();
        $data['link'] = DB::table('friend_link')->where('status',0)->lists();
        $data['member'] = Auth::guard('member')->user();

        return view('home.index',$data);
    }


//    //获取地址 通过cid
//    public function getArea(Request $request)
//    {
//        $cid = $request->cid;
//        if(isset($cid)) {
//            $title = DB::table('article')->where('cid', $cid)->lists();
//        }
//        if($title) return Show::success(200,'ok',$title);
//        Show::error();
//        print_r($title);
//    }
}
